﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GemCraftLabyrinthHelper
{
    public static class Rule
    {
        public static CalculatedData Calculate(int forgeSkill,
            int replenishSkill, int waveManaPerMonster,
            int violentExplosionsSkill, double manaPoolMultiplier)
        {
            double violentExplosionsIncrease = (violentExplosionsSkill / 100D) + 1;
            double forgeSkillDecrease = 1 - (forgeSkill / 100D);
            
            double replenishSkillIncrease = 1 + (replenishSkill / 100D);

            int[] adjustedMPS = new int[GCData.MonsterPerSummon.Length];
            GCData.MonsterPerSummon.CopyTo(adjustedMPS, 0);

            int[] adjustedCPG = new int[GCData.MonsterPerSummon.Length];
            GCData.CostPerGem(forgeSkillDecrease).CopyTo(adjustedCPG, 0);

            List<double> totalManaGain = new List<double>();
            List<double> profitPerSummon = new List<double>();

            for (int i = 0; i < adjustedMPS.Length; i++)
            {
                adjustedMPS[i] = (int)Math.Round(adjustedMPS[i] * violentExplosionsIncrease);

                double manaGain = waveManaPerMonster * replenishSkillIncrease * manaPoolMultiplier * adjustedMPS[i];
                double profit = manaGain - adjustedCPG[i];
                totalManaGain.Add(manaGain);
                profitPerSummon.Add(profit);
            }

            return new CalculatedData(totalManaGain, profitPerSummon, adjustedMPS, adjustedCPG);
        }
    }
}
